package com.dacong.nezha.utils;

import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

/**
 * Description:
 * Author: xucong
 * Date: 2025/2/23 16:26
 */
public class Tongji {



    public static void main(String[] args) {

    }

    public static BigDecimal profile(String token){
        String param = "{\n" +
                "    \"url\": \"/me/profile\",\n" +
                "    \"options\": {\n" +
                "        \"method\": \"GET\",\n" +
                "        \"headers\": {\n" +
                "            \"Authorization\": \""+token+"\",\n" +
                "            \"Language\": \"zh-CN\"\n" +
                "        }\n" +
                "    }\n" +
                "}";
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(param));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getBigDecimal("asset");

    }

    /**
     * 养号准备中
     * @return
     */
    public static Integer yanghaoWait(String token){

        String url = "/ck/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":50,\"status\":\"3\"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }

    /**
     * 养号养号中
     * @return
     */
    public static Integer yanghaoing(String token){

        String url = "/ck/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":50,\"status\":\"4\"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }

    /**
     * 养号完成数
     * @return
     */
    public static Integer yanghaoFinish(String token){

        String url = "/ck/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":50,\"status\":\"5\"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }

    public static Integer todayXiadan(String token){
        long start = DateUtil.beginOfDay(new Date()).getTime();
        long end = DateUtil.endOfDay(new Date()).getTime();
        String url = "/assetFlow/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":10,\"flowType\":\"下单交易\",\"beginTime\":"+start+",\"endTime\":"+end+"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }

    public static Integer todayYanghao(String token){
        long start = DateUtil.beginOfDay(new Date()).getTime();
        long end = DateUtil.endOfDay(new Date()).getTime();
        String url = "/assetFlow/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":10,\"flowType\":\"养号交易\",\"beginTime\":"+start+",\"endTime\":"+end+"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }

    public static Integer todayPeifu(String token){
        long start = DateUtil.beginOfDay(new Date()).getTime();
        long end = DateUtil.endOfDay(new Date()).getTime();
        String url = "/assetFlow/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":10,\"flowType\":\"赔付\",\"beginTime\":"+start+",\"endTime\":"+end+"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }

    public static Integer todaytuikuan(String token){
        long start = DateUtil.beginOfDay(new Date()).getTime();
        long end = DateUtil.endOfDay(new Date()).getTime();
        String url = "/assetFlow/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":10,\"flowType\":\"退款\",\"beginTime\":"+start+",\"endTime\":"+end+"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }

    public static Integer zhunbeizhong(String token){
        String url = "/slink/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":100,\"status\":\"3\"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }

    public static Integer yixiadan(String token){
        String url = "/mallOrder/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":50,\"status\":\"1\"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }

    public static Integer shensuzhong(String token){
        String url = "/mallOrder/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":50,\"status\":\"4\"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }

    public static Integer tuikuanzhong(String token){
        String url = "/mallOrder/list";
        String method = "POST";
        String param = "{\"page\":0,\"size\":50,\"status\":\"6\"}";
        Map<String, Object> body = Request.createBody(url, method, param, token);
        String s = ExcuteHttp.executeHttp(JSONUtil.toJsonStr(body));
        JSONObject entries = JSONUtil.parseObj(s);
        return entries.getInt("totalElements");
    }
}
